<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="renderer" content="webkit" />
<title>无标题文档</title>
<link href="__PUBLIC__/admin/sncss/css/style.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/admin/sncss/css/combo.select.css" rel="stylesheet" type="text/css" />
<!-- <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/simditor/styles/simditor.css" /> -->
<script src="__PUBLIC__/js/jquery1.8.3.js"></script>
<script language="javascript" type="text/javascript" src="__PUBLIC__/admin/datepicker/WdatePicker.js"></script>
<script type="text/javascript">
//时间选择
function selecttime(){
	WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});
}
</script>
</head>

<body>

	<div class="place">
	<span>位置：</span>
	<ul class="placeul">
	<li><a>首页</a></li>
	<li><a>订单管理</a></li>
	<li><a>创建订单</a></li>
	</ul>
	</div>

	<div class="formbody">

	<div class="formtitle"><span>创建订单</span></div>
<form id="formid" name="form1" method="post" action="{:U('/Home/Order/CreateOrder')}" onsubmit="return form1_submit();">
	<ul class="forminfo">
	<!-- <li><label>新手单</label>
    <label><input name="newsingle" type="radio" value="0" checked="checked"/>否</label>
    <label><input name="newsingle" type="radio" value="1" />是</label>
  </li>
	<li><label>虚拟订单</label>
    <label><input name="isdummy" type="radio" value="0" checked="checked"/>否</label>
    <label><input name="isdummy" type="radio" value="1" />是</label>
  </li> -->
  <li><label>订单种类</label>
    <label><input name="ordertype" type="radio" value="1" />虚拟订单</label>
    <label><input name="ordertype" type="radio" value="0" checked="checked"/>新手单</label>
  </li>
	<li>
	<div style="width: 86px;line-height: 34px;display: block;float: left;">自媒体</div>
	<div class="dowebok" style="float: left;">
	<select name="media" id="media" >
		<option value="">请选择</option>
		<?php foreach ($medialist as $key => $value) { ?>
		<option value="<?php echo $value['id'];?>"><?php echo $value['media_name'];?></option>
		<?php }?>
	</select>
	</div>
	</li>
	<li>
	<div style="width: 86px;line-height: 34px;display: block;float: left;">专辑</div>
	<div class="dowebok" style="float: left;">
	<select name="special" id="special" >
		<option value="0">不选择专辑</option>
	</select>
	</div>
	</li>
	<li><label>订单类型</label>
    <label><input name="demand" type="radio" value="1" onchange="demandchange()" checked="checked"/>正常单</label>
    <!-- <label><input name="demand" type="radio" value="2" onchange="demandchange()" />加急单</label> -->
    <!-- <label><input name="demand" type="radio" value="3" onchange="demandchange()" />预约单</label> -->
  </li>
	<li><label>声音类型</label>
    <label><input name="soundtype" type="radio" value="1" checked="checked"/>讲述类</label>
    <label><input name="soundtype" type="radio" value="2" />情感类</label>
    <label><input name="soundtype" type="radio" value="3" />演绎类</label>
    <label><input name="soundtype" type="radio" value="4" />新闻类</label>
    <label><input name="soundtype" type="radio" value="5" />英文类</label>
  </li>
	<li><label>性别</label>
    <label><input name="sex" type="radio" value="0" checked="checked"/>全部</label>
    <label><input name="sex" type="radio" value="1" />男</label>
    <label><input name="sex" type="radio" value="2" />女</label>
  </li>
  <li><label>语速</label>
    <label><input name="speed" type="radio" value="1" checked="checked"/>正常</label>
    <label><input name="speed" type="radio" value="2" />快</label>
    <label><input name="speed" type="radio" value="3" />慢</label>
  </li>
	<li><label>链接</label><input name="user_url" id="user_url" type="text" class="lginput" value="" />
	<input type="button" id="get_url" class="btn" value="获取"/></li>
	<li><label>标题</label><input name="title" id="title" type="text" class="lginput" value="" /><i></i></li>
	<li><label>文章</label><textarea style="float: left;" name="article" id="article" onkeyup="cal_words()" ></textarea><i></i></li>
	<li><br><label style="width: 120px;">总字数<i id="num">0</i>个</label><label style="width: 120px;">预计用时<i id="ptime">0</i>分</label>
	<label style="width: 160px;">等级：<select name="level" id="level" class="newselect" onchange="change_level()" >
		<?php foreach ($leveldata as $key => $value) { ?>
		<option value="<?php echo $value['id'];?>"><?php echo $value['message'];?></option>
		<?php }?>
	</select>级</label>
	<label style="width: 220px;">预计花费<i id="cost">0</i>元<i id="discount_message"></i></label>
	</li>
	<li><label>定时</label><input type="text" style="width: 140px;" class="dfinput ordertimebody1" name="ordertiming" id="ordertiming" onfocus="selecttime()" value="" size="17" class="date" readonly><i></i></li>


	<input name="wordnumber" id="wordnumber" type="hidden" value="" /><!-- 字数 -->
	<input name="expectedtime" id="expectedtime" type="hidden" value="" /><!-- 预计用时 -->
	<input name="moneynumber" id="moneynumber" type="hidden" value="" /><!-- 原价 -->
	<input name="usemoney" id="usemoney" type="hidden" value="" /><!-- 实价 -->
	<?php foreach ($leveldata as $key => $value) { ?>
	<input id="use_money<?php echo $value['id'];?>" type="hidden" value="<?php echo $value['money'];?>" />
	<?php }?>
	<input id="demandval" type="hidden" value="1" name="demandval" /><!-- 订单类型 -->
	<input id="mintime" type="hidden" value="" name="mintime" /><!-- 订单时长 -->
	<input id="delayed" type="hidden" value="" name="delayed" /><!-- 订单加时 -->
	<input id="perprice" type="hidden" value="" name="perprice" /><!-- 订单变价 -->
	<li></li>

	<li><label>&nbsp;</label>
	<input type="submit" class="btn" id="overflow" value="创建订单"/>
	</li>
	</ul>
</form>

	</div>


</body>

<script src="__PUBLIC__/admin/Js/jquery-1.7.2.min.js"></script>
<script src="__PUBLIC__/layer/layer.js"></script>
<script src="__PUBLIC__/admin/Js/jquery.combo.select.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/ueditor/lang/zh-cn/zh-cn.js"></script>

<script type="text/javascript">
var editor = UE.getEditor('article',{    //content为要编辑的textarea的id
	initialFrameWidth: 800,   //初始化宽度
	initialFrameHeight: 200,   //初始化高度
});
editor.addListener('keyup',function(){
		cal_words();
 })
</script>
<script>
$(function() {
	$('#media').comboSelect();
	$('#special').comboSelect();
});
</script>
<script type="text/javascript">
function form1_submit(){

	var media= $('#media').val();
	if(media.length == 0){
		layer.msg('请选择自媒体');return false;
	}
	var title = $.trim($('#title').val());
	if (title.length == 0) {
		layer.msg('请填写标题');return false;
	};
	var article = UE.getEditor('article').getContentTxt();
	if(article.length == 0){
		layer.msg('请录入文章');return false;
	}
	var level=$('#level').val();
	if(level.length == 0){
		layer.msg('请选择等级');return false;
	}
	$("#overflow").attr("disabled","disabled");
	layer.load(1, {shade: [0.8, '#393D49']});
}
//用word方式计算正文字数
function fnGetCpmisWords(str){
	sLen = 0;
	try{
		str = str.replace(/(\r\n+|\s+|　+)/g,"龘");
		str = str.replace(/[\x00-\xff]/,"m");
		str = str.replace(/m+/g,"*");
		str = str.replace(/龘+/g,"");
		sLen = str.length;
	}catch(e){}
	return sLen;
}

function cal_words(){
	//获取纯文本内容
	var ue = UE.getEditor('article');
	var text = ue.getContentTxt();

	// alert(text);
	var max_mun = 100;//字数设置，上线时改成100
	// var article= $('#article').val();
	var length = fnGetCpmisWords(text);
	// alert(length);
	document.getElementById("num").innerHTML = length;
	document.getElementById("wordnumber").value = length;
	var level=$('#level').val();
	var levelmoney=$('#use_money'+level).val();
	if (length < max_mun) {
		var usemoney = Number(levelmoney);
		// alert(levelmoney);
	}else{
		var user_num = Math.ceil(length/max_mun);
		var usemoney = Number(levelmoney*user_num);
	}

	var demandval=$('#demandval').val();/*类型*/
	var mintime=$('#mintime').val();/*时长*/
	var delayed=$('#delayed').val();/*加时*/
	var perprice=$('#perprice').val();/*变价*/
	var costmoney = usemoney;

	if (demandval == 2) {
		var costmoney = usemoney*(1+perprice/100);
		document.getElementById("discount_message").innerHTML = "(加价"+perprice+"%)";
	}
	if (demandval == 3) {
		var costmoney = usemoney*(1-perprice/100);
		document.getElementById("discount_message").innerHTML = "(优惠"+perprice+"%)";
	}
	document.getElementById("cost").innerHTML = costmoney.toFixed(2)*2;
	document.getElementById("moneynumber").value = usemoney.toFixed(2);
	document.getElementById("usemoney").value = costmoney.toFixed(2);

	var pertime = mintime/60;
	var plantime = Math.ceil(length/max_mun);
	var usetime = Number(Math.ceil(plantime*pertime)+Math.ceil(delayed/60));
	document.getElementById("ptime").innerHTML = usetime;
	document.getElementById("expectedtime").value = usetime;
}

var max_time			= <?php echo $systemdata['6']['value']?>;		/*加急单时长*/
var max_delayed		= <?php echo $systemdata['7']['value']?>;		/*加急单加时*/
var max_price			= <?php echo $systemdata['8']['value']?>;		/*加急单加价*/
var order_time		= <?php echo $systemdata['9']['value']?>;		/*普通单时长*/
var order_delayed	= <?php echo $systemdata['10']['value']?>;	/*普通单加时*/
var min_time			= <?php echo $systemdata['11']['value']?>;	/*预约单时长*/
var min_delayed		= <?php echo $systemdata['12']['value']?>;	/*预约单加时*/
var min_price			= <?php echo $systemdata['13']['value']?>;	/*预约单折扣*/
$('#demandval').val(1);$('#mintime').val(order_time);$('#delayed').val(order_delayed);$('#perprice').val(0);
function demandchange(){
		var demandval = $('input:radio[name="demand"]:checked').val();
		// alert(demandval)
		if (demandval == 1) {$('#demandval').val(1);$('#mintime').val(order_time);$('#delayed').val(order_delayed);$('#perprice').val(0);}
		if (demandval == 2) {$('#demandval').val(2);$('#mintime').val(max_time);$('#delayed').val(max_delayed);$('#perprice').val(max_price);}
		if (demandval == 3) {$('#demandval').val(3);$('#mintime').val(min_time);$('#delayed').val(min_delayed);$('#perprice').val(min_price);}
		cal_words();
}
function change_level(){
	cal_words();
}
</script>

<script type="text/javascript">
	$(document).ready(function(){
		$('#media').change(function(){
			var media_id = $(this).val();
			$.get("/Home/Order/media_ajax",{media_id:media_id},function(data){
				// alert(data.media.isvip);
				$(".special_option").remove();
				for (var i = 0; i < data.special.length; i++) {
					var option = '<option class="special_option" value="'+data.special[i].id+'" selected>'+data.special[i].specialname+'</option>';
					$("#special").append(option);
				}
				$('#special').comboSelect();
			},'json');
		});
	});
</script>
<script type="text/javascript">
	$(document).ready(function(){
		$('#get_url').click(function(){
			var user_url = $('#user_url').val();
			$.post("/Home/Order/getwebcontent",{user_url:user_url},function(data){
				// alert(data.title);
				$('#title').val(data.title);
        UE.getEditor('article').setContent(data.message);
				cal_words();
			},'json');
		});
	});
</script>
</html>
